#ifndef WOLF_LAYER_TEST_HPP
#define WOLF_LAYER_TEST_HPP

#include "test.hpp"
#include "layer.hpp"
namespace wolf {
/**
 * @brief Tests if the layer system is working
 *
 * It creates a layer and inserts it on the engine.
 **/
class LayerTest: public Test {
public:
	LayerTest() :
			Test("Layers") {
	}
	~LayerTest() {
	}

	/**
	 * @brief A test layer that just show a colored rectangle
	 *
	 *
	 **/
	class RectangleLayer: public Layer {
	public:
		/**
		 * @brief Creates a new rectangle with the given color, rect and depth
		 *
		 *
		 **/
		RectangleLayer(const SDL_Color &color, const SDL_Rect & rect, int depth) :
				Layer(depth), _rect(rect), _color(color) {
		}

		void draw(SDL_Surface *dst) {
			SDL_FillRect(dst, &_rect,
					SDL_MapRGB(dst->format, _color.r, _color.g, _color.b));
		}

	private:
		SDL_Rect _rect;
		SDL_Color _color;
	};

	bool run() {
		Engine engine(Engine::RELEASE);
		engine.setVideoMode(640, 480, 0);
		engine.setFrameRate(30);

		engine.start();

		RectangleLayer bigRed(( SDL_Color ){255, 63, 63	}, ( SDL_Rect ){0, 0, 128, 128}, 100); //back
		RectangleLayer smallBlue(( SDL_Color ){63, 63, 255}, ( SDL_Rect ){96, 96, 32, 32}, 0); //front
		RectangleLayer mediumGreen(( SDL_Color ){63, 255, 63}, ( SDL_Rect )	{64, 64, 64, 64	}, 50); // middle

		// If it is really working, you can change the order of adding and the show order still the same
//		engine.addLayer(bigRed);
//		engine.addLayer(smallBlue);
//		engine.addLayer(mediumGreen);

		//
		while (engine.isRunning()) {
			engine.doFrame();
		}
		engine.halt();
		return true;
	}
};

}

#endif // WOLF_LAYER_TEST_HPP
